package work;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class AutoCloseableDemo {
    public static void main(String[] args) {
        //try()语句中只能定义实现了autocloseable的类
        try(
               // String a="";
             //  Integer i=34;
              // File f=new File("fos.txt");
                FileInputStream fileInputStream=new FileInputStream("fos.txt");
        ){
            byte[] data=new byte[100];
            fileInputStream.read(data);
            System.out.println(new String(data, StandardCharsets.UTF_8));
        }catch(Exception e){
            System.out.println(e);
        }
    }



}
